#!/bin/bash
source $CFG

java -Xmx2g -jar $GENOMICS_JAR/MarkDuplicates.jar \
VALIDATION_STRINGENCY=SILENT \
INPUT=s_${1}.bam \
OUTPUT=s_${1}_nodup.bam \
TMP_DIR=$TMPDIR  \
REMOVE_DUPLICATES=false \
CREATE_INDEX=true \
METRICS_FILE=metrics \
OPTICAL_DUPLICATE_PIXEL_DISTANCE=10

samtools view -bq 1 s_${1}_nodup.bam -o s_${1}_nodup_uniq.bam

if [ -s s_${1}_nodup_uniq.bam ]
then
 samtools index s_${1}_nodup_uniq.bam
else
 exit 100
fi
